package com.blog.cloud.dao;

import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.blog.cloud.comm.modal.pojo.UserUploadInf;
import com.blog.cloud.comm.webutils.CommMethod;
import com.jfinal.plugin.activerecord.Page;

public class UserUploadInfDao extends UserUploadInf {
	
	public static UserUploadInfDao me = new UserUploadInfDao();
	public String tabName = CommMethod.getTbaleName("UserUploadInf");
	
	
	
	public void insert(UserUploadInf userUploadInf ){
		userUploadInf.save();
	}
	public void update(UserUploadInf userUploadInf ){
		userUploadInf.update();
	}
	
	
	
	
	public Page<UserUploadInf> geetUserUploadInfPage(String userNo , String tagNo   , int pageNumber  , int pageSize){
		String select =" select b.*  ";
		String sql = "  FROM lexy_gallery_tags a LEFT JOIN lexy_user_upload_inf b ON a.user_upload_inf_id = b.serial_id where 1=1 ";
		if(StringUtils.isNotEmpty(userNo)){
			sql += " AND b.upload_user = '"+userNo+"'";
		}
		if(StringUtils.isNotEmpty(tagNo)){
			sql += " AND a.tag_no like '%"+tagNo+"%'";
		}
		
		sql += " ORDER BY update_time desc ";
		
		return dao.paginate(pageNumber, pageSize, select, sql);
	}
	
	
	
	
	public List<UserUploadInf> geetUserUploadInfList( String fileName){
		String sql = " select * from  "+ tabName + " where file_name = ? ";
		return dao.find(sql, fileName);
		
	}
	
	

}
